﻿Public Class EntityDAO
    Public Function getConnectionString(ByVal databaseName As String, ByVal typeDatabase As String) As String
        Dim connectionString As String = Settings.Default.ConnectionStr
        Dim modelName As String = "silm_global"

        If typeDatabase = DatabaseType.TYPE_GLOBAL Then
            modelName = "silm_global"

        ElseIf typeDatabase = DatabaseType.TYPE_SPECIFIC Then
            modelName = "silm_site"
            If databaseName IsNot Nothing Then
                Dim tokens As String() = connectionString.Split(";")
                tokens(1) = "Initial Catalog=" & databaseName
                connectionString = tokens(0) & ";" & tokens(1) & ";" & tokens(2) & ";" & tokens(3)
            End If
        End If
        connectionString = "metadata=res://*/" & modelName & ".csdl|res://*/" & modelName & ".ssdl|res://*/" & modelName & ".msl;provider=System.Data.SqlClient;provider connection string='" & connectionString & ";MultipleActiveResultSets=True'"
        Return connectionString

    End Function
End Class
